#include <iostream>
#include <cstring>
#include <unordered_set>
using namespace std;
using ull=unsigned long long;
const ull base=131;
const int N=1e6+10;
ull h1[N],h2[N],b[N];
int sum[N];


unordered_set<char> has;
void init(string s)
{
	memset(h1,0,sizeof(h1));
	memset(h2,0,sizeof(h2));
	memset(sum,0,sizeof(sum));
	int n=s.size();
	for(int i=1;i<n;i++)
	{
		sum[i]=sum[i-1]+has.count(s[i]);
	}
	b[0]=1;
	for(int i=1;i<n;i++)
	{
		h1[i]=h1[i-1]*base+s[i]-'a'+1;
		b[i]=b[i-1]*base;
	}
	
	for(int i=n-1;i>=1;i--)
	{
		h2[i]=h2[i+1]*base+s[i]-'a'+1;
	}
}
ull getPre(int l,int r)
{
	return h1[r]-h1[l-1]*b[r-l+1];
}
ull getSub(int l,int r)
{
	return h2[l]-h2[r+1]*b[r-l+1];
}
int getSum(int l,int r)
{
	return sum[r]-sum[l-1];
}

int main()
{
	int t;
	cin>>t;
	has.clear();
	has.insert('l');
	has.insert('q');
	has.insert('b');
	while(t--)
	{
		string s;
		cin>>s;
		int n=s.size();
		s=' '+s;
		init(s);
		bool flg=false;
		for(int i=1;i*2-1<=n && !flg;i++)
		{
			if(getPre(1,i)==getSub(i,2*i-1) && getSum(2*i,n)==n-2*i+1)
				flg=true;
			if(getPre(1,i)==getSub(i+1,2*i) && getSum(2*i+1,n)==n-2*i)
				flg=true;

		}
		if(flg)
			cout<<"Yes"<<endl;
		else 
			cout<<"No"<<endl;
	}
	return 0;
}
